#include "contiki.h"
#include <stdbool.h>
#include <stdint.h>

static volatile clock_time_t ticks;
void clock_init(void) {
  // already initilaze by bsp
}
/*---------------------------------------------------------------------------*/
clock_time_t clock_time(void) {
  return ticks;
}
/*---------------------------------------------------------------------------*/
void clock_update(void) {
  ticks++;
  if (etimer_pending()) {
    etimer_request_poll();
  }
}
/*---------------------------------------------------------------------------*/
unsigned long clock_seconds(void) {
  return (unsigned long)(ticks / CLOCK_CONF_SECOND);
}
/*---------------------------------------------------------------------------*/
void clock_wait(clock_time_t i) {
  clock_time_t start;
  start = clock_time();
  while (clock_time() - start < (clock_time_t)i) {
  }
}
/*---------------------------------------------------------------------------*/
void clock_delay_usec(uint16_t dt) {
  extern void bsp_delay_us(uint32_t cnt);
  bsp_delay_us(dt);
}

void clock_delay(unsigned int i) {
  clock_delay_usec(i);
}
/*---------------------------------------------------------------------------*/
/**
 * @}
 * @}
 * @}
 */